Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Conflicting engine parameters and link-supplied credential overrides remain unresolved.
2 open findings
What changed in this PR
Adds native Extract API support through the existing client request flow.
Changes:
- Adds
extractandextract_linkhelpers. - Adds unit specifications and live examples for extraction modes.
- Documents usage and updates the class-length limit.
| File | Description |
|---|---|
| spec/serpapi/client/extract_api_spec.rb | Tests helpers and validation. |
| spec/serpapi/client/example/example_extract_spec.rb | Exercises scrape, map, and crawl. |
| README.md | Documents extraction and link following. |
| lib/serpapi/client.rb | Implements Extract API helpers. |
| lib/serpapi.rb | Loads URI parsing support. |
| demo/demo_extract.rb | Demonstrates modes and chained extraction. |
| CHANGELOG.md | Records Extract API support. |
| .rubocop.yml | Raises the class-length limit. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| .transform_keys(&:to_sym) | ||
| raise SerpApiError, "link does not target the extract engine: #{link}" if link_params[:engine] != 'extract' | ||
|
|
||
| search(link_params.merge(params)) |
| raise SerpApiError, "params must be hash, not: #{params.class}" unless params.instance_of?(Hash) | ||
| raise SerpApiError, 'url parameter is required by the extract API' if params[:url].to_s.empty? && params['url'].to_s.empty? | ||
|
|
||
| search(params.merge(engine: 'extract')) |
Add first-class support for the Extract API (engine: extract), which turns any public web page into a structured JSON document and supports scrape (default), map, and crawl modes. New method on SerpApi::Client: - extract(params): runs an extraction; forces engine=extract and fails fast when the required :url parameter is missing. All other parameters (mode, max_pages, max_depth, include_subdomains, include_sitemap, device, prefetch_delay, timeout, include_tags, exclude_tags, include_markdown, include_inline_assets, output) pass through verbatim - the backend remains the source of truth. Includes offline unit specs, live example specs, a runnable demo (demo/demo_extract.rb), and README documentation.
extract forced engine: 'extract' with a symbol key, so a string-keyed 'engine' from the call or the client defaults was sent as well (engine=google&engine=extract). Drop string-keyed engines and nil out any inherited from the defaults.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Let's add first-class support for the Extract API (
engine=extract), which turns any public web page into a structured JSON document and supportsscrape(default),map, andcrawlmodes.The new
extract(params)methodRuns an extraction. Forces
engine: 'extract'and fails fast withSerpApiErrorwhen the required:urlparameter is missing. All other parameters (mode,max_pages,max_depth,include_subdomains,include_sitemap,device,prefetch_delay,timeout,include_tags,exclude_tags,include_markdown,include_inline_assets,output) pass through verbatim, keeping the backend as the source of truth for validation. The hash-only signature matches the gem's existing convention (search(q: ...)) and mirrors the planned Python SDK shape (client.extract(url=...)).